//
//  TitleMenuViewController.m
//  VisitorFacetestingSystem
//
//  Created by 张斌 on 16/7/14.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "TitleMenuViewController.h"

#import "DropdownMenuView.h"

@interface TitleMenuViewController ()

@property (nonatomic, strong) NSMutableArray * data;

@end

@implementation TitleMenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _data = [NSMutableArray array];
    [_data addObject:@"全部"];
    [_data addObject:@"今天"];

    [self.tableView reloadData];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.tableView.backgroundColor = [UIColor colorWithRed:65/255.0 green:66/255.0 blue:67/255.0 alpha:1.0];
    
    self.tableView.showsVerticalScrollIndicator = NO; 
    

}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"statusCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    
    NSString * name = _data[indexPath.row];
    cell.textLabel.text = name;
    
    cell.backgroundColor = [UIColor colorWithRed:65/255.0 green:66/255.0 blue:67/255.0 alpha:1.0];
    
    cell.textLabel.textColor = [UIColor whiteColor];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

#pragma mark Cell点击事件处理器
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    
//    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
//    
//    cell.textLabel.textColor = [UIColor blueColor];
//    
//    cell.backgroundColor = [UIColor colorWithRed:103/255.0 green:104/255.0 blue:105/255.0 alpha:1.0];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (_dropdownMenuView) {
        [_dropdownMenuView dismiss];
    }
    
    if (_delegate) {
        [_delegate selectAtIndexPath:indexPath title:_data[indexPath.row]];
    }
    
}


@end
